define(function(require, exports, module) {
    var ALL = require("../../common/all"),
        CONFIG = ALL.CONFIG,
        Dialog = ALL.Dialog,
        METHOD = ALL.METHOD,
        Init = ALL.Init;


    var _Dialog = new Dialog({
        title : "提示",
        content : "<p></p>",
        text4Btn: ["确定", "取消"],
        class4Btn: ["", "line"]
    });

    var id = METHOD.getQueryParms("id");

    var _vm = Init.initVue({
        data : {
            check: {},
            show : false,
            res : null
        },
        methods: {
            changePhone : function(){
                this.show = true;
            },
            checkPhone : function(){

                if (!_vm.phone) {
                    METHOD.alert("变更手机号不能为空，请输入新手机号");
                    return;
                } else if (new String(_vm.phone).length < 11) {
                    METHOD.alert("你输入的手机号有误，请确认新手机号");
                    return;
                } else if (_vm.phone == _vm.res.phone ){
                    METHOD.alert("你尚未变更手机号，请确认新手机号");
                    return;
                }

                _Dialog.changeCfg({
                    content : "<p>确定将该用户的手机号修改为</p><p><span class='m_main'>"+ _vm.phone+ "</span>吗?</p>",
                });
                _Dialog.showUI(function(i) {
                    if (i == 0) {
                        METHOD.ajax("user/phone/modify",{
                            id: _vm.res.id,
                            phone: _vm.phone
                        }, {type:"post"}).done(function(json){
                            METHOD.alert("修改成功").done(function(){
                                _vm.show = false;
                                _vm.getData();
                            });
                        });
                    }
                    this.hideUI();
                });
            },
            changeCard : function(){
                _Dialog.changeCfg({
                    content : "<p>确定将该用户的银行卡号修改为<span class='m_main'>"+ _vm.res.bankcard+ "</span>吗</p>",
                });
                _Dialog.showUI(function(i) {
                    if (i == 0) {
                        METHOD.ajax("user/bankcard/modify",{
                            id:_vm.res.id,
                            bankcard:_vm.res.bankcard
                        }, {type:"post"}).done(function(json){
                            METHOD.alert("修改成功");
                        });
                    }
                    this.hideUI();
                });
            },
            getData : function() {
                METHOD.loading.show();
                METHOD.ajax("user/detail",{id:id}).done(function(json){
                    METHOD.loading.hide();
                    _vm.res = json.data;
                }).fail(function(){
                    METHOD.loading.hide();
                })
            }
        }
    });


    if (id) {
        _vm.getData();
    }
});
